<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>任务首页 </title>

    <link rel="stylesheet" th:href="@{/static/iview/iview.css}">
    <script th:src="@{/static/libs/jquery-3.2.1.min.js}" type="text/javascript"></script>
	<script th:src="@{/static/libs/vue.min.js}" type="text/javascript"></script>
	<script th:src="@{/static/layer/layer.js}" type="text/javascript"></script>
   <script th:src="@{/static/iview/iview.min.js}" type="text/javascript"></script>
	<script th:src="@{/static/common.js}" type="text/javascript"></script>
    <style type="text/css">
	[v-cloak] {
			  display: none;
			}
	</style>
</head>
<body>
<div id="app" v-cloak>
        <div style="margin-bottom: 6px;margin: 30px">
			<i-input v-model="content" placeholder="交易编号"  style="width: 200px"></i-input>
		    <i-select  v-model="updown"  style="width: 100px" @on-change="changupdownlist"  placeholder="类型">
		              <i-option v-for="item in updownlist"  :value="item.id"  :key="item.value">{{item.value}} </i-option>
		     </i-select> 
		     <i-select  v-model="transtype"  style="width: 150px" @on-change="changtranstypelist"  placeholder="交易类型" >
		              <i-option v-for="item in transtypelist"  :value="item.id"  :key="item.value">{{item.id}} - {{item.value}} </i-option>
		     </i-select> 
		      <i-select  v-model="processresult"  style="width: 120px" @on-change="changprocessresultlist"  placeholder="处理结果">
		              <i-option v-for="item in processresultlist"  :value="item.id"  :key="item.value">{{item.id}} - {{item.value}} </i-option>
		     </i-select> 
		     <date-picker type="datetime" v-model="startTime" placeholder="开始时间" :options="startTimeOption" @on-change="onStartTimeChange"   style="width: 153px" ></date-picker>
		    -
		     <date-picker type="datetime" v-model="endTime" placeholder="结束时间" :options="endTimeOption" @on-change="onEndTimeChange"   style="width: 153px" ></date-picker>
			<i-button type="primary" @click="search()" icon="ios-search">搜索</i-button>
			<i-button type="primary" @click="empty()" icon="ios-close-empty">清空</i-button>
		</div>
		<div style="margin-bottom: 6px;margin: 30px">
			<template> 
				<i-table border :content="self" :columns="tableTitle" :data="datalist"></i-table>
			 	<br>
<!-- 			 	<Page :total="dataCount" :page-size="pageSize" show-total @on-change="changepage" @on-page-size-change="changePageSize"></Page> -->
			 	<!--分页功能-->
				<Page :current="pageNo" :total="dataCount" :page-size="pageSize"  @on-change="changepage"  @on-page-size-change="changePageSize"  show-elevator show-sizer show-total ></Page>
				 
			</template>
		</div>
</div>
<script type="text/javascript">
var vm = new Vue({
	el : '#app',
	data : {
		content : '',
		pageNo : 1,
		pageSize : 10,// 每页显示多少条
		dataCount:"", // 总数据的条目
		datalist: [], //接口获取的总数据
		historyData:'',//展示的数据 
		transtype:'',
	    transtypelist:[],
		updown:'',
		updownlist:[{"id":"","value":"请选择"},{"id":"4401","value":"原始交易"},{"id":"4402","value":"刷卡交易"},{"id":"4403","value":"其他交易"},{"id":"4404","value":"冲正交易"},{"id":"4405","value":"其他下载交易"}], 
		processresult:'',
		processresultlist:[
			{"id":"","value":"请选择"},
			{"id":"-2","value":"已发送未反馈"},
			{"id":"-1","value":"未发送"},
			{"id":"0","value":"正常记账"},
			{"id":"1","value":"争议待决"},
			{"id":"2","value":"争议后付款"},
			{"id":"3","value":"争议后拒付"}
			],
		startTime: '',
        endTime: '',
        startTimeOption: {},
        endTimeOption: {},
		tableTitle:[ 
		{
				   title : "编号",
				   type: 'index',
				   align: 'center',
		            width: 70
		 },
		{
				key : "gid",
				title : "交易编号"
		}, 
		{
			key : "packageNo",
			title : "包号",
			width : 155
		}, 
		{
			key : "transId",
			title : "序列号",
			width : 80
		}, 
		{
			key : "transTypeCode",
			title : "交易类型",
			width : 150,
			render : function(h, params) {
				var text =params.row.transTypeCode;
				if(params.row.transTypeCode == 1){
					text =" - 原始交易①";
				}else if(params.row.transTypeCode == 2){
					text =" - 刷卡交易";
				}else if(params.row.transTypeCode == 3){
					text =" - 原始交易②";
				}else if(params.row.transTypeCode == 4){
					text =" - 原始交易③";
				}else if(params.row.transTypeCode == 5){
					text =" - 原始交易④";
				}else if(params.row.transTypeCode == 12 || params.row.transTypeCode == 13){
					text =" - 其他交易";
				}else if(params.row.transTypeCode == 14){
					text =" - 冲正交易";
				}else if(params.row.transTypeCode == 10){
					text =" - 省域拆分 - ETC";
				}else if(params.row.transTypeCode == 11){
					text =" - 省域拆分 - 现金";
				}else if(params.row.transTypeCode == 6){
					text =" - 记账";
				}else if(params.row.transTypeCode == 7){
					text =" - 争议处理结果";
				}else if(params.row.transTypeCode == 8){
					text =" - 清分结算结果";
				}else if(params.row.transTypeCode == 9){
					text =" - 清分结算结果（非ETC）";
				}else if(params.row.transTypeCode == 14){
					text =" - 其他冲正交易";
				}else if(params.row.transTypeCode == 15){
					text =" - 交易退费消息";
				}else if(params.row.transTypeCode == 16){
					text =" - 交易补交消息";
				}else if(params.row.transTypeCode == 17){
					text =" - 移动支付长款";
				}else if(params.row.transTypeCode == 18){
					text =" - 清分结算结果（退费补交）";
				}else if(params.row.transTypeCode == 19){
					text =" - 移动支付交易争议";
				}else if(params.row.transTypeCode == 31){
					text =" - 跨省刷卡交易";
				}else if(params.row.transTypeCode == 32){
					text =" - 跨省其他交易";
				}else if(params.row.transTypeCode == 33){
					text =" - 省内门架交易";
				}else if(params.row.transTypeCode == 34){
					text =" - 省内刷卡交易";
				}else if(params.row.transTypeCode == 35){
					text =" - 省内其他交易";
				}
				return h('div',params.row.transTypeCode + text);
			}
		}, 
		{
			key : "issuerId",
			title : "发行方"
		}, 
		{
			key : "multiProvince",
			title : "单/多省"
		}, 
		{
			key : "processResult",
			title : "处理结果",
		    render : function(h, params) {
					var text =params.row.processResult;
					if(params.row.processResult == -2){
						text ="已发送未反馈";
					}else if(params.row.processResult == -1){
						text ="未发送";
					}else if(params.row.processResult == 0){
						text ="正常记账";
					}else  if(params.row.processResult == 1){
						text ="争议待决";
					}else 	if(params.row.processResult == 2){
						text ="争议后付款";
					}else if(params.row.processResult == 3){
						text ="争议后拒付";
					}
					return h('div',params.row.processResult+ " - "+ text);
		    }
		}, 
		{
			key : "processReason",
			title : "记帐处理结果"
		}, 
		{
			key : "lastProcessTime",
			title : "最后处理时间",
			width : 150,
			render : function(h, params) {
				var text = "";
				if(params.row.lastProcessTime !=null){
					 text =  formatDate(new Date(params.row.lastProcessTime),'yyyy-MM-dd hh:mm:ss') ;
				}
				return h('div',text);
			}
		}, 
		 {
			key : "createTime",
			title : "创建时间",
			width : 150,
			render : function(h, params) {
				if(params.row.createTime !=null){
					return formatDate(new Date(params.row.createTime),'yyyy-MM-dd hh:mm:ss');
				}
			}
		}]
	},
	methods : {
		search : function(){
			this.pageNo = 1;
			this.loadlist(1);
		},
		empty : function(){
			vm.content = '';
			vm.updown = '';
			vm.transtype='';
			vm.processresult = '';
			vm.startTime='';
			vm.endTime='';
			
			this.pageNo = 1;
			
			$("li").removeClass("ivu-page-item-active");
			changepage(1);
		},
		//任务列表(自行实现分页)
		loadlist : function(index) {
			var page = {};
			page['pageIndex']= (index == 'undefind' ? 0: index) ;
			page['pageSize']= this.pageSize;
					
			var params = {};
		
			if(this.conten!=''){
			    params['gid'] = this.content.trim();
			}	
			if(this.transtype!=''){
				params['transTypeCode']=parseInt(this.transtype);
			}	
			if(this.processresult!=''){
				params['processResult']=parseInt(this.processresult);
			}	
			if(this.startTime !=''){
				params['beginTime'] =  formatDate(new Date(this.startTime),'yyyy-MM-dd hh:mm:ss');
			}
			
			if(this.endTime !=''){
				params['endTime'] =  formatDate(new Date(this.endTime),'yyyy-MM-dd hh:mm:ss');
			}
			
			if(this.startTime !='' && this.endTime ==''){
				params['endTime'] = formatDate(new Date(),'yyyy-MM-dd hh:mm:ss'); 
			}else if(this.startTime =='' && this.endTime !=''){
				params['beginTime'] = formatDate(new Date(),'yyyy-MM-dd hh:mm:ss'); 
			}
			 
			
			 var conditional = {};
			 conditional['page'] = page;
			 conditional['params'] = params;
			 
			var json =  JSON.stringify(conditional);
			
			$.ajax({
				url:"../clear/getClearPendingCharges",
				type:"post",
				dataType: "json",
				contentType: 'application/json', 
				data: json,
				success: function(data) {
					vm.datalist = data.result.rows;
					vm.dataCount = data.result.total; //接口返回数据的总条目数
					if(vm.dataCount < vm.pageSize){   
                        vm.historyData   = vm.JobData
                    }else{
                        vm.historyData = vm.datalist.slice(0,self.pageSize);
                    }
				}
			});
		}, 
        changepage:function(index){
			this.loadlist(index);
        },
        changePageSize:function(num) { 
           this.pageSize = num;
           this.changepage(1);
       }, 
       changtranstypelist:function(value){
    	   vm.transtype=value;
       },
       changupdownlist:function(value){
    	   vm.updown = value;
    	   if(value == 4401){
    		   vm.transtypelist = [
    			   {"id":"","value":"请选择"},
    			   {"id":"1","value":"基于①"},
    			   {"id":"3","value":"基于②"},
    			   {"id":"4","value":"基于③"},
    			   {"id":"5","value":"基于④"}
    			   ];
    	   }else if(value == 4402){
    		   vm.transtypelist = [
    			   {"id":"","value":"请选择"},
    			   {"id":"2","value":"ETC刷卡交易"}
    			   ];
    	   }else if(value == 4403){
    			  vm.transtypelist = [
    			   {"id":"","value":"请选择"},
       			   {"id":"12","value":"移动支付交易"},
       			   {"id":"13","value":"现金交易"}
       			   ];
    		}else  if(value == 4404){
    	    	  vm.transtypelist = [
    	    	   { "id":"","value":"请选择"},
       			   {"id":"14","value":"其他冲正交易"}
       			   ];
    	   }else{
    		   vm.transtypelist = [
    			   {"id":"6","value":"记账"},
    			   {"id":"7","value":"争议处理结果"},
    			   {"id":"8","value":"清分结算结果"},
    			   {"id":"9","value":"清分结算结果(非ETC)"},
    			   {"id":"10","value":"省域拆分 - ETC"},
    			   {"id":"11","value":"省域拆分 - 现金"},
    			   {"id":"14","value":"其他冲正交易"},
    			   {"id":"15","value":"交易退费消息"},
    			   {"id":"16","value":"交易补交消息"},
    			   {"id":"17","value":"移动支付长款"},
    			   {"id":"18","value":"清分结算结果(退费补交)"},
    			   {"id":"19","value":"移动支付交易争议"}
    			   ]  
    	   }
       },
       changprocessresultlist:function(value){
    	   vm.respons = value;
       },
       onStartTimeChange:function(startTime, type) {
           this.endTimeOption = {
               disabledDate(endTime) {
                   return endTime < new Date(startTime) || endTime > Date.now();
               }
           };
       },
       onEndTimeChange:function(endTime, type) {
           this.startTimeOption = {
               disabledDate(startTime) {
                   return startTime > new Date(endTime) || startTime > Date.now();
               }
           };
       },
		edit : function(quartz){
			dialogOpen({
				title: '修改',
				url: 'task/add.shtml',
				//屏幕小 滚动条显示
				scroll : true,
				width: '450px',
				height: '450px',
				success : function(iframeId){
					top.frames[iframeId].vm.formQuartz = quartz;
				},
				yes : function(iframeId) {
					top.frames[iframeId].vm.acceptClick();
				},
			});
		},
		//移除任务
		remove : function(jobName,jobGroup){
			var that = this;
			top.layer.confirm('确定要移除任务吗？', {btn: ['确定','取消']}, function(){
				$.ajax({
					url:"../job/remove",
					type:"post",
					data:{'time':(new Date()).toString(),"jobName":jobName,'jobGroup':jobGroup},
					success: function(result) {
						if(result.code=="0"){
							top.layer.msg('任务移除成功', {icon: 1});
							window.setTimeout(that.loadlist(),1500); 
						}
					}
				});
			});
		}
	},
	created : function() {
		 this.loadlist();
        // this.changepage(1);
         /* this.transtypedroplist(); */
	}
})

</script>
</body>
</html>